﻿/**  版本信息模板在安装目录下，可自行修改。
* DepartmentNew.cs
*
* 功 能： N/A
* 类 名： DepartmentNew
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2013-4-18 15:57:45   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Collections.Generic;

namespace DMZS.BLL
{
    /// <summary>
    /// DepartmentNew
    /// </summary>
    public partial class DepartmentNew
    {
        private readonly DMZS.DAL.DepartmentNew dal = new DMZS.DAL.DepartmentNew();
        public DepartmentNew()
        {
        }

        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DMZS.Model.DepartmentNew model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DMZS.Model.DepartmentNew model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {
            return dal.Delete(ID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            return dal.DeleteList(IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DMZS.Model.DepartmentNew GetModel(int ID)
        {
            return dal.GetModel(ID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public DMZS.Model.DepartmentNew GetModelByCache(int ID)
        {
            var CacheKey = "DepartmentNewModel-" + ID;
            var objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(ID);
                    if (objModel != null)
                    {
                        var ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch
                {
                }
            }
            return (DMZS.Model.DepartmentNew)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DMZS.Model.DepartmentNew> GetModelList(string strWhere)
        {
            var ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<DMZS.Model.DepartmentNew> DataTableToList(DataTable dt)
        {
            var modelList = new List<DMZS.Model.DepartmentNew>();
            var rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                DMZS.Model.DepartmentNew model;
                for (var n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList(string.Empty);
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        /// <summary>
        /// 获取数据行
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public DataRow GetRecordByID(int ID)
        {
            return dal.GetRecordByID(ID);
        }
        /// <summary>
        /// 增加一条数据 扩展
        /// </summary>
        public int AddExpand(DMZS.Model.DepartmentNew model)
        {
            return dal.AddExpand(model);
        }

        /// <summary>
        /// 增加一条数据 扩展
        /// </summary>
        public int UpdateExpand(DMZS.Model.DepartmentNew model)
        {
            return dal.UpdateExpand(model);
        }


        /// <summary>
        /// 获得数据列表 扩展
        /// </summary>
        /// <param name="TypeID">类型ID, 0:全部</param>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public DataSet GetListForUIExpand(int TypeID, string strWhere)
        {
            return dal.GetListForUIExpand(TypeID, strWhere);
        }
        /// <summary>
        /// 第一条
        /// </summary>
        /// <returns></returns>
        public DataRow GetFirst()
        {
            return dal.GetFirst();
        }
        /// <summary>
        /// 最后一条记录
        /// </summary>
        /// <returns></returns>
        public DataRow GetLast()
        {
            return dal.GetLast();
        }
        /// <summary>
        /// 上一条记录
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public DataRow GetPrevious(int ID)
        {
            return dal.GetPrevious(ID);
        }

        /// <summary>
        /// 下一条记录
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public DataRow GetNext(int ID)
        {
            return dal.GetNext(ID);
        }
        public DataSet GetDataSetForTree()
        {
            return dal.GetDataSetForTree();
        }
        /// <summary>
        /// 获取数据行
        /// </summary>
        /// <param name="Code"></param>
        /// <returns></returns>
        public DataRow GetRecordByCode(string Code)
        {
            return dal.GetRecordByCode(Code);
        }

        public DataSet GetListForUIExpand(string strWhere)
        {
            return dal.GetListForUIExpand(strWhere);
        }



        public int GetChildrenCount(int ID)
        {
            return dal.GetChildrenCount(ID);
        }

        public int DeleteExpand(int ID)
        {
            return dal.DeleteExpand(ID);
        }

        public DataSet GetListForDialog(string Code, string Name)
        {
            return dal.GetListForDialog(Code, Name);
        }
    }
}

